//
//  Global.h
//  PriceOnline
//
//  Created by Phuong Dinh Le on 1/25/13.
//  Copyright (c) 2013 WorkLikeDance. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum
{
    NewsTypeItem,
    NewsTypeCard
} NewsType;

#define HTTP_REPONSE_OK 200

#define iOS7AppStoreURLFormat @"itms-apps://itunes.apple.com/app/id706625889"
#define iOS6AppStoreURLFormat @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=706625889"

#define RECT(__x__,__y__,__w__,__h__) CGRectIntegral(CGRectMake(__x__,__y__,__w__,__h__))
#define SIZE(__w__,__h__) CGSizeMake(__w__, __h__)
#define POINT(__x__,__y__) CGPointMake(__x__,__y__)

#define DEFAULT_ANIMATION_VECLOCITY 1400
#define DEFAULT_SLOWEST_SPEED_TIME 0.4

#define LOGO_WID 160
#define LOGO_HEI 60
#define LOGO_MARGIN 16
#define MENU_WID (LOGO_WID + LOGO_MARGIN*2)

#define FONT(__x__) [UIFont systemFontOfSize:__x__]
#define FONT_BOLD(__x__) [UIFont boldSystemFontOfSize:__x__]
//#define FONT_HELVETICANEUE(__x__)           [UIFont fontWithName:@"HelveticaNeue" size:__x__]
//#define FONT_HELVETICANEUE_BOLD(__x__)      [UIFont fontWithName:@"HelveticaNeue-Bold" size:__x__]
//#define FONT_HELVETICANEUE_ITALIC(__x__)    [UIFont fontWithName:@"HelveticaNeue-Italic" size:__x__]

#define IS_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_IOS7 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
#define IS_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_IOS8 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")

//
#define Is_Landscape (([[UIApplication sharedApplication] statusBarOrientation]) == UIInterfaceOrientationLandscapeLeft || ([[UIApplication sharedApplication] statusBarOrientation]) == UIInterfaceOrientationLandscapeRight)

//Color
#define COLOR_HEX_ALPHA(rgbValue, alphaValue) [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0f green:((rgbValue & 0xFF00) >> 8)/255.0f blue:(rgbValue & 0xFF)/255.0f alpha:alphaValue*1.0f]

#define COLOR_HEX(rgbValue) COLOR_HEX_ALPHA(rgbValue, 1.0f)

#define COLOR(__r__,__g__,__b__,__a__)    [UIColor colorWithRed:__r__*1.0/255.0 green:__g__*1.0/255.0 blue:__b__*1.0/255.0 alpha:__a__*1.0]

#define COLOR_HIGHLIGHT_TITLE [UIColor greenColor]
#define COLOR_RED_NORMAL COLOR(254, 69, 60, 1)
#define COLOR_RED_DARK COLOR(192,28,18, 1)

#define INFO_ENTITY @"Info"
#define WEBSITE_ENTITY @"Website"
#define MARKED_WEBSITE_ENTITY @"MarkedWebsite"

#define VERSION_KEY @"version"
#define WEBSITE_KEY @"website"
#define MARKED_WEBSITE_KEY @"markedWebsite"
#define ICON_KEY @"icon"
#define TITLE_KEY @"title"
#define DESCRIPTION_KEY @"des"
#define URL_KEY @"url"
#define ORDER_KEY @"order"
#define CREATED_DATE_KEY @"createdDate"
#define LINK_KEY @"link"
#define UNREAD_NEWS_COUNT_KEY @"unreadNewsCount"

#define NEW_TYPES_KEY @"NewsType"

//light style
#define COLOR_BACKGROUND_LIGHT COLOR(239,239,244,1)
#define COLOR_BACKGROUND_CELL_LIGHT COLOR(255,255,255,1)
#define COLOR_TEXT_HEADER_LIGHT COLOR(0,0,0,1)//133,133,138,1)
#define COLOR_TEXT_ORANGE_LIGHT COLOR(255, 149, 0, 1);
#define COLOR_BACKGROUND_PULL_TO_REFRESH_LIGHT COLOR(230,230,240,1)
#define COLOR_BACKGROUND_MENU COLOR(36, 36, 36, 1)

//black style
#define COLOR_BACKGROUND_PULL_TO_REFRESH_DARK COLOR(99,99,99,1)
#define COLOR_TEXT_ORANGE_DARK COLOR(246, 197, 70, 1)
#define COLOR_BACKGROUND_HEADER_DARK COLOR_HEX(0x4C4C4B)
#define COLOR_TEXT_HEADER_DARK COLOR(173,173, 173, 1)
#define COLOR_BLACK COLOR(0,0,0,1)
#define COLOR_LIGHT_BLACK COLOR(79,79,79,1)
#define COLOR_ORANGE COLOR(246,197,70,1)
#define COLOR_DARK_ORANGE COLOR(202,141,19,1)
#define COLOR_WHITE COLOR(240,240,240,1)
#define COLOR_LIGHT_GRAY COLOR(231,231,231,1)
#define COLOR_TEXT_LIGHT_GRAY COLOR(158,158,158,1)
#define COLOR_BLUE_IOS7 COLOR(0,105,245,1)
#define COLOR_RED COLOR(229,0,0,1)
#define COLOR_GREEN_NORMAL COLOR(1,212,5,1)
#define COLOR_DARK_GREEN COLOR(1,162,5,1)


#pragma mark - Device Macro
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )
#define IS_IPOD   ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPod touch" ] )
#define IS_IPHONE_5 ( IS_IPHONE && IS_WIDESCREEN )
#define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define IS_PORTRAIT ( UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) )
#define DEVICE_ORIENTATION [[UIApplication sharedApplication] statusBarOrientation]
#define IS_PHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#define __SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_70  SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(iOS_7_0)
#define __SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_80  SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(iOS_8_0)

#define iOS_8_0 @"8.0"

typedef enum
{
    ThreadRun = 0,
    ThreadPause,
    ThreadStop
} ThreadStatus;



